home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Commun⁄Network / macworkstation msg ƒ / MWS_EXEC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-27  |  1.8 KB  |  87 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Mac Workstation glue to build exec code with LightSpeedC 4.0
  3.  * The project type must be code resource
  4.  * Check the box for custom header in the project type
  5.  * Created 12:36:21 AM  10/26/89 by Aaron Wohl, aw0g+@andrew.cmu.edu
  6.  * Probably needs LightspeedC 4.0, haven't tried 3.xx
  7.  */
  8.  
  9. #include "mws.h"
  10. #include "mws_exec.h"
  11.  
  12. /*define this to breakpoint on entry for debugging*/
  13. /* #define DEBUG_EXEC_GLUE */
  14.  
  15. long mws_a4;
  16.  
  17. /******* DANGER ********
  18.  * this is where execution begins, not because it is called main
  19.  * but because this is the fist code in the .c file that contains main()
  20.  * so don't add any functions before this one in this file
  21.  */
  22. void proper_a4()
  23. {
  24.     asm{
  25.         bra.s    @exec_start
  26.         dc.w    0        /*flags word*/
  27.         dc.b    'MWSX'    /*type*/
  28.         dc.w    0        /*ID*/
  29.         dc.w    0x5358    /*version*/
  30.         dc.l    0        /*unused*/
  31. exec_start:
  32. #ifdef DEBUG_EXEC_GLUE
  33.         _Debugger
  34. #endif
  35.         move.l a4,a1
  36.         lea main,a4
  37.         move.l a1,mws_a4
  38.         move.l (sp)+,a0    /*return address*/
  39.         move.l (sp)+,d1 /*argument handle*/
  40.         move.w (sp)+,d0    /*tl code*/
  41.         move.l a0,-(sp)
  42.         move.w d0,-(sp)
  43.         move.l d1,-(sp)
  44.         jsr    exec_main
  45.         move.w mws_a4,a4
  46.         rts
  47. #ifdef DEBUG_EXEC_GLUE
  48. exec_msg:
  49.         dc.b "exec glue entry\000"
  50. #endif
  51.     }
  52. }
  53.  
  54. void CallMWS(void *msg,ProcPtr proc);
  55. void CallMWS(void *msg,ProcPtr proc)
  56. {
  57.     asm {
  58.         move.l a4,-(sp)        /*save my a4*/
  59.         move.l msg,-(sp)
  60.         move.l proc,a0
  61.         move.l mws_a4,a4
  62.         jsr (a0)
  63.         move.l (sp)+,a4
  64.     };
  65. }
  66.  
  67.  
  68. void MWS_Command(TPMsg theMsg,THExecRef execRef)
  69. {
  70.     CallMWS(theMsg,(*execRef)->xMWSTable[mwsCommand]);
  71. }
  72.  
  73. void MWS_Send(TPMsg theMsg,THExecRef execRef)
  74. {
  75.     CallMWS(theMsg,(*execRef)->xMWSTable[mwsSend]);
  76. }
  77.  
  78. void MWS_Receive(TPMsg theMsg,THExecRef execRef)
  79. {
  80.     CallMWS(theMsg,(*execRef)->xMWSTable[mwsReceive]);
  81. }
  82.  
  83. void MWS_GetAlias(TPAlias theMsg,THExecRef execRef)
  84. {
  85.     CallMWS(((TPMsg)theMsg),(*execRef)->xMWSTable[mwsGetAlias]);
  86. }
  87.